﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace QuestionSetLibrary
{
    class Run
    {

        static void Main()
        {
            //Setting part
            QuestionSet questionSet = new QuestionSet("Research name");
            Question q1 = new MultipleChoiceQuestion();
            q1.setQuestionName("How long XXXX");
            q1.addAnswer("1km");
            q1.addAnswer("2km");
            questionSet.addQuestion((MultipleChoiceQuestion)q1);
            Question q2 = new TextQuestion();
            q2.setQuestionName("How many XXXX");
            questionSet.addQuestion((TextQuestion)q2);

            //Getting part
            Console.WriteLine("You are doing this question set: " + questionSet.getSetName());
            Console.WriteLine("The First question is: " + questionSet.getQuestionName(0));
            //if the current question is an MC question:
            if (questionSet.getQuestion(0).GetType() == typeof(MultipleChoiceQuestion))
            {
                for (int i = 0; i < ((MultipleChoiceQuestion)questionSet.getQuestion(0)).getAnswers().Count; i++)
                {
                    Console.WriteLine(i  + ". " + ((MultipleChoiceQuestion)questionSet.getQuestion(0)).getAnswer(i).getAnswerString());
                }
                String choice = Console.ReadLine();
                int currentChoice = Convert.ToInt16(choice) - 1;
                Console.WriteLine("you have choose " + currentChoice + ". " + ((MultipleChoiceQuestion)questionSet.getQuestion(0)).getAnswer(currentChoice).getAnswerString());
            }

            Console.WriteLine("The Second question is: " + questionSet.getQuestionName(1));
            
            //if the current question is an Text question:
            if (questionSet.getQuestion(1).GetType() == typeof(TextQuestion))
            {
                String text = Console.ReadLine();
                Console.WriteLine("you have entered: " + text);
            }
            Console.ReadLine();
        }
    }
}
